/*
 * TestDumpGbl.c
 *
 *  Created on: 2012/05/30
 *      Author: guanxiaoying
 */

#include "TestDump.h"

TYPE_KEY_LIST stKeyList[] = {
		{ "Record", XML_RECORD },
		{ "DB_FILEINFO", XML_FILE },
		{ "DB_CODESCOPE", XML_CODESCOPE },
		{ "DB_LINKAGE", XML_LINKAGE },
		{ "DB_TYPE", XML_TYPE },
		{ "DB_SYMBOL", XML_SYMBOL },
		{ "DB_CONSTANT", XML_CONSTANT },
		{ "DB_DECLARATION", XML_DECLARATION },
		{ "DB_TYPESPECIFIER", XML_TYPESPECIFIER },
		{ "DB_DECLARATOR", XML_DECLARATOR },
		{ "DB_INITIALIZER", XML_INITIALIZER },
		{ "DB_STATEMENT", XML_STATEMENT },
		{ "DB_EXPRESSION", XML_EXPRESSION },
		{ "DB_DESIGNATION", XML_DESIGNATION },
		{ "DB_STRING", XML_STRINGLITERAL },
		{ "DB_UNITECHAIN", XML_UNITECHAIN },
		{ "DB_PPTOKEN", XML_PPTOKENLIST },
		{ "DB_DIRECTIVE", XML_DIRECTIVE },
		{ "DB_MACROINFO", XML_MACROINFO },
		{ "DB_PPCONDEXP", XML_PPCONDEXP },
		{ "DB_REPLIST_TOKEN", XML_REPLSTTKN },
		{ "VALUE", XML_VALUE },
		{ "STRING", XML_STRINGVALUE },
		{ "FLAG", XML_FLAG },
		{ "LOCATION", XML_LOCATION },
		{ "KIND", XML_KIND },
		{ "NAME", XML_NAME },
		{ "ILLEGAL", XML_ERROR }
};
char * const top_header = "<%s>\n";
char * const top_end = "</%s>\n";
char * const header_format = "<%s index=\"%ld\">\n";
char * const tail_format = "</%s>\n";
char * const sub_tab_header_format = "\t<%s property=\"%s\" index=\"%ld\">";
char * const sub_tab_tail_format = "</%s>\n";
char * const sub_value_header_format = "\t<%s property=\"%s\">";
char * const sub_value_tail_format = "</%s>\n";
CHAR file_buf[OS_FULLPATH+4];
CHAR tempBuf[OS_FULLPATH+64];
CHAR constantBuffer[50];
PSZ dumpGetStr( U2 id ){
	int i = 0;
	for( i = 0; stKeyList[i].id != XML_ERROR; i++ ){
		if( stKeyList[i].id == id ){
			break;
		}
	}
	return stKeyList[i].key;
}
VOID dumpXMLConvert( CHAR c, PSZ str ){
//	&lt; represents "<"
//	&gt; represents ">"
//	&amp; represents "&"
//	&apos; represents '
//	&quot; represents "
	if( c == '<' ){
		strcpy( str, "&lt;" );
	}else if( c == '>' ){
		strcpy( str, "&gt;" );
	}else if( c == '&' ){
		strcpy( str, "&amp;" );
	}else if( c == '\'' ){
		strcpy( str, "&apos;" );
	}else if( c == '"' ){
		strcpy( str, "&quot;" );
	}else{
		str[0]=c;
		str[1]=0;
	}
}
